package edu.scau.mis.web.controller.pos;

import edu.scau.mis.system.domain.Log;
import edu.scau.mis.system.service.ILogService;
import edu.scau.mis.core.domain.AjaxResult;
import org.springframework.web.bind.annotation.*;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
/**
 * 操作日志(Log)表控制层
 *
 * @author CJW
 * @since 2022-09-14 22:13:20
 */
@RestController
@RequestMapping("log")
public class LogController {
    /**
     * 服务对象
     */
    @Autowired
    private ILogService logService;


    /**
     * 分页查询数据列表
     *
     * @param log 筛选条件
     * @return 查询结果
     */
    @GetMapping("/page")
    public AjaxResult page(@RequestParam("pageNum") Integer pageNum, @RequestParam("pageSize") Integer pageSize, Log log) {
        PageHelper.startPage(pageNum,pageSize);
        List<Log> list = this.logService.selectList(log);
        PageInfo<List> pageInfo = new PageInfo(list);
        return AjaxResult.success(pageInfo);
    }

    /**
     * 批量删除数据
     *
     * @param logIds 主键
     * @return 删除是否成功
     */
    @DeleteMapping("/delete/{logIds}")
    public AjaxResult deleteById(@PathVariable Long[] logIds) {
        System.out.println(logIds);
        return AjaxResult.success(this.logService.deleteByIds(logIds));
    }
}

